package com.dries.portal.browser.controller;

import com.dries.portal.browser.vo.User;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.ServletWebRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Description:
 * @Author ZSY
 * @createTime 2020/9/16 15:27
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private ProviderSignInUtils providerSignInUtils;

    @PostMapping("/register")
    public void register(HttpServletRequest request, User user) {

        // 不管是注册用户还是绑定用户，都会拿到一个用户唯一标识
        String userId = user.getUsername();
        providerSignInUtils.doPostSignUp(userId, new ServletWebRequest(request));

    }

}
